package com.myplans.client.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.myplans.client.presenter.ViewPlanPresenter.Display;

public class ViewPlanView extends Composite implements Display {

	private static ViewPlanViewUiBinder uiBinder = GWT
			.create(ViewPlanViewUiBinder.class);

	interface ViewPlanViewUiBinder extends UiBinder<Widget, ViewPlanView> {
	}
	
	@UiField
	FlowPanel planPanel;
	@UiField Label name;
	@UiField Label location;
	@UiField Label date;
	@UiField Label description;
	@UiField Label user;
	@UiField FlowPanel participantsPanel;
	@UiField Button attendingButton;
	boolean isAttending = false;
	
	public void setIsAttending(boolean isAttending) {
		attendingButton.setVisible(true);
		this.isAttending = isAttending;
		if (isAttending) {
			attendingButton.setStyleName("myButton-Attending");
			attendingButton.setText("Attending");
		} else {
			attendingButton.setStyleName("myButton");
			attendingButton.setText("Attend");
		}
	}
	
	public boolean isAttending() {
		return isAttending;
	}

	public Button getAttendingButton() {
		return attendingButton;
	}

	public FlowPanel getParticipantsPanel() {
		return participantsPanel;
	}

	public Label getUser() {
		return user;
	}

	public Label getName() {
		return name;
	}

	public Label getLocation() {
		return location;
	}

	public Label getDate() {
		return date;
	}

	public Label getDescription() {
		return description;
	}

	public ViewPlanView() {
		initWidget(uiBinder.createAndBindUi(this));
		attendingButton.setVisible(false);
	}

	public ViewPlanView(String firstName) {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public FlowPanel getPlanPanel() {
		return planPanel;
	}

}
